/* eslint-disable */
<template>
	<div class="accountAssignMange">
	<!-- 显示搜索符合条件的列表部分 -->
		<div class="userCollapse" >
			<el-form class='searchform' :inline="true" :model="searchListForm" ref="searchListForm" label-width="140px">
				<el-row>
					<el-col :span="24" class="flex flex-vc rowItem">
						<el-button  @click="showcollse=!showcollse" class="showsearchBtn" type="info"
							:icon="showcollse?'el-icon-caret-top':'el-icon-caret-bottom'"  size="mini" >{{showcollse?$t('common.collseHide'):$t('common.spread')}}</el-button>
						<span class="searchTitle flex-vc inline_flex flex-hc">{{$t('searchEaraLabel.accountAndEmp')}}</span>
						<div class="userCollapse_item" v-if="showcollse">
							<el-form-item :label="$t('common.byUserName')+'：'" prop="byUserName">
								<el-input v-model="searchListForm.byUserName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.byStatus')+'：'" prop="byStatus">
								<el-select v-model="searchListForm.byStatus" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option v-for="(item,index) in byStatusOptions" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('modules.accountAssignManage.empCode')+'：'"  prop="empCode">
								<el-input v-model="searchListForm.empCode" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('modules.accountAssignManage.empName')+'：'" prop="empName">
								<el-input v-model="searchListForm.empName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.empStatus')+'：'" prop="empStatus">
								<el-select v-model="searchListForm.empStatus" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option v-for="(item,index) in empStatusOptions" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('common.positionName')+'：'" prop="positionName">
								<el-input v-model="searchListForm.positionName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.orgName')+'：'" prop="orgName">
								<el-input v-model="searchListForm.orgName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.netCode')+'：'" prop="netCode">
								<el-input v-model="searchListForm.netCode" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
						</div>
						<div class="userCollapse_hide" v-if="!showcollse">
							<span>{{$t('common.byUserName')}}:</span><strong>【{{searchListForm.byUserName?searchListForm.byUserName:$t('common.all')}}】</strong>
							<span>{{$t('common.byStatus')}}:</span><strong>【{{getSearchAreaName('byStatus')}}】</strong>
							<span>{{$t('modules.accountAssignManage.empCode')}}:</span><strong>【{{searchListForm.empCode?searchListForm.empCode:$t('common.all')}}】</strong>
							<span>{{$t('modules.accountAssignManage.empName')}}:</span><strong>【{{searchListForm.empName?searchListForm.empName:$t('common.all')}}】</strong>
							<span>{{$t('common.empStatus')}}:</span><strong>【{{getSearchAreaName('empStatus')}}】</strong>
							<span>{{$t('common.positionName')}}:</span><strong>【{{searchListForm.positionName?searchListForm.positionName:$t('common.all')}}】</strong>
							<span>{{$t('common.orgName')}}:</span><strong>【{{searchListForm.orgName?searchListForm.orgName:$t('common.all')}}】</strong>
							<span>{{$t('common.netCode')}}:</span><strong>【{{searchListForm.netCode?searchListForm.netCode:$t('common.all')}}】</strong>

						</div>
					</el-col>
					<el-col :span="24" class="flex flex-vc rowItem">
						<span class="searchTitle flex-vc inline_flex flex-hc">{{$t('searchEaraLabel.sysAndRole')}}</span>
						<div class="userCollapse_item" v-if="showcollse">
							<el-form-item :label="$t('common.subsysName')+'：'" prop="subSystemName">
								<el-select  v-model="searchListForm.subSystemName" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option  v-for="(item,index) in subsysTemOptions" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('common.roleName')+'：'" prop="roleName">
								<el-input v-model="searchListForm.roleName" :placeholder="$t('common.inputPlaceholder')"></el-input>
							</el-form-item>
							<el-form-item :label="$t('common.roleStatus')+'：'" prop="roleStatus">
								<el-select v-model="searchListForm.roleStatus" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option v-for="(item,index) in roleStatusOptions" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
						</div>
						<div class="userCollapse_hide" v-if="!showcollse">
							<span>{{$t('common.subsysName')}}:</span><strong>【{{getSearchAreaName('subsysName')}}】</strong>
							<span>{{$t('common.roleName')}}:</span><strong>【{{searchListForm.roleName?searchListForm.roleName:$t('common.all')}}】</strong>
							<span>{{$t('common.roleStatus')}}:</span><strong>【{{getSearchAreaName('roleStatus')}}】</strong>

						</div>
					</el-col>
					<el-col :span="24" class="flex flex-vc rowItem">
						<span class="searchTitle flex-vc inline_flex flex-hc">{{$t('searchEaraLabel.assign')}}</span>
						<div class="userCollapse_item" v-if="showcollse">
							<el-form-item :label="$t('common.ruleType')+'：'" prop="ruleType">
								<el-select v-model="searchListForm.ruleType" :placeholder="$t('common.selectPlaceholder')" clearable>
									<el-option v-for="(item,index) in ruleTypeOptions" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item :label="$t('common.startTm')+'：'" prop="startTm">
								<el-date-picker v-model="searchListForm.startTm"  type="date"  value-format="yyyy-MM-dd"  :placeholder="$t('common.selectDate')"></el-date-picker>
							</el-form-item>
							<el-form-item  :label="$t('common.endTm')+'：'" prop="endTm">
								<el-date-picker v-model="searchListForm.endTm"  type="date"  value-format="yyyy-MM-dd" :placeholder="$t('common.selectDate')" > </el-date-picker>
							</el-form-item>
							<el-form-item :label="$t('modules.accountAssignManage.status')+'：'" prop="status">
								<el-select v-model="searchListForm.status" :placeholder="$t('common.selectPlaceholder')" >
									<el-option v-for="(item,index) in statusOptions" :key="index" :label="item.label" :value="item.value"></el-option>
								</el-select>
							</el-form-item>
						</div>
						<div class="userCollapse_hide" v-if="!showcollse">
							<span>{{$t('common.ruleType')}}:</span><strong>【{{getSearchAreaName('ruleType')}}】</strong>
							<span>{{$t('common.startTm')}}:</span><strong>【{{searchListForm.startTm?searchListForm.startTm:$t('common.all')}}】</strong>
							<span>{{$t('common.endTm')}}:</span><strong>【{{searchListForm.endTm?searchListForm.endTm:$t('common.all')}}】</strong>
							<span>{{$t('modules.accountAssignManage.status')}}:</span><strong>【{{getSearchAreaName('status')}}】</strong>

						</div>
					</el-col>
				</el-row>
			</el-form>
		</div>
	<!-- 显示搜索符合条件的列表部分 -->
	<!-- 操作表格数据的部分 -->
	<el-row>
		<el-col :span="18">
			<div class="operateBtn">
				<el-button  @click="handleRoleAssignVisible=true" >{{$t('modules.accountAssignManage.add')}}</el-button>
				<el-button  @click="handleRoleBatchVisible=true" >{{$t('modules.accountAssignManage.batchAdd')}}</el-button>
				<el-button  @click="midifyRole()" >{{$t('modules.accountAssignManage.modify')}}</el-button>
				<!-- 2018/08/06修改启用禁用按钮，禁用角色授权之后不能再启用，所以将启用/禁用改为禁用-->
				<el-button  @click="batchDisabled()">{{$t('modules.accountAssignManage.disabled')}}</el-button>
			</div>
		</el-col>
		<el-col :span="6">
            <div class="searchBtn">
				<el-button type="primary" @click="onSearch" >{{$t('common.searchBtn')}}</el-button>
				<el-button  type="primary" @click="resetSearch('searchListForm')" >{{$t('common.resetBtn')}}</el-button>
			</div>
		</el-col>
	</el-row>
	<!-- 操作表格数据的部分 -->
	<!-- 角色授权列表部分 -->
	<el-table class="data-list "  @row-dblclick="dbmidifyRole" v-loading="loadind" ref="accountAssignList" :data="accountAssignList" border @selection-change="changeSelectedRoleList" highlight-current-row>
		<el-table-column  type="selection" width="55"  fixed="left"></el-table-column>
		 <el-table-column v-for="(col,index) in tableVisibleArr" :key="index" :prop="col.prop" :label="col.label" align="center" :formatter="formatter" show-overflow-tooltip>
		</el-table-column> 
	</el-table>
	<!-- 角色授权列表部分 -->
	<!-- 表格下面的分页和自定义表格部分 -->
	<div class="tablebottom" style="position:relative;">
		<el-pagination
		@size-change="pageSizeChange"
		@current-change="handleCurrentChangePage"
		:current-page="pagination.pageNum"
		:page-sizes="[10,20, 50, 100, 200]"
		:page-size="pagination.pageSize"
		layout="->,prev, pager, next, jumper, sizes,total"
		:total="pagination.totalSize">
		</el-pagination>
		<!-- 自定义表格字段部分 -->
        <defined-table :headArr="accountAssignTableHeader" storageName="basp_accountAssignManage" :selectArr="tableVisibleArr" @saveAutoDefinedTable="saveAutoDefinedTable"></defined-table>
		<!-- 自定义表格字段部分 -->
	</div>
	<!-- 表格下面的分页和自定义表格部分 -->
	<!-- 修改或者授权有效时间的弹窗 -->
	<validity-date :visible="modifyRoleValidityVisible"  :earliestTime="new Date().getTime()"  :start="$format(currentParentDate.startTm,'yyyy-MM-dd')"  :end="$format(currentParentDate.endTm,'yyyy-MM-dd')" @validityDateClose="modifyRoleValidityClose" @submitDateForm="submitRoleValidity"></validity-date>
	<!--新增角色授权操作弹框-->
	<handle-role :visible="handleRoleAssignVisible"  @exit="giveupFun('handleRoleAssignVisible')"   @close="handleRoleAssignVisible=false;" @roleHandleSave="roleHandleSave"></handle-role>
   <!--新增角色批量授权操作弹框-->
	<handle-role-batch :visible="handleRoleBatchVisible"  @exit="giveupFun('handleRoleBatchVisible')"   @close="handleRoleBatchVisible=false;" @roleHandleSave="roleHandleBatchSave"></handle-role-batch>
	<!--点击分配角色弹窗-->
	</div>
</template>
<script>
import { Message, Notification, MessageBox, Loading } from 'element-ui'
import validityDate from "../components/validityDate"
import definedTable from "../components/definedTable"
import handleRole from "../components/handleRole"
import handleRoleBatch from "../components/handleRoleBatch"
export default {
		name: 'accountAssignManage',
    components: {
        validityDate,
        definedTable,
        handleRole,
        handleRoleBatch
    },
    data () {
        return {
            showcollse: false,
            loadind: false,
            modifyRoleValidityVisible: false,
            addRoleValidityVisible: false,
            showDefaultRoleVisible: false,
            startRoleValidityVisible: false, // 将角色状态改为启用状态的时候
            rowObject: {},
            rules1: {
                subSysCode: [
                    { required: true, message: this.$t('validateWornText.selectSubSysCode'), trigger: 'change' }
                ],
                byUserName: [
                    { required: true, message: this.$t('validateWornText.inputByAccount'), trigger: 'change' }
                ]
            },
            pagination: {
                totalSize: 0,
                pageSize: 10,
                pageNum: 1,
                totalPage: 0
            },
            searchListForm: {
                byUserName: "",
                byStatus: '',
                // 员工检索
                empCode: "",
                empName: "",
                empStatus: '',
                positionName: "",
                orgName: "",
                netCode: "",
                // 子系统检索
                subSystemName: "",
                // 角色检索
                roleName: "",
                roleStatus: '',
                // 授权检索
                ruleType: "",
                startTm: "",
                endTm: "",
                status: 1
            },
            accountAssignList: [],
            // 传当前组件的时间到子组件;
            currentParentDate: {},
            // 传当前组件的时间到子组件;
            accountAssignTableHeader: [
                { prop: "byUserName", label: this.$t('common.byUserName'), index: 0 },
                { prop: "byStatus", label: this.$t('common.byStatus'), index: 1 },
                { prop: "empCode", label: this.$t('common.empCode'), index: 2 },
                { prop: "empName", label: this.$t('common.empName1'), index: 3 },
                { prop: "positionName", label: this.$t('common.positionName'), index: 4 },
                { prop: "orgName", label: this.$t('common.orgName'), index: 5 },
                { prop: "netCode", label: this.$t('common.netCode'), index: 6 },
                { prop: "empStatus", label: this.$t('common.empStatus'), index: 7 },
                { prop: "systemName", label: this.$t('common.systemName'), index: 8 },
                { prop: "subSystemName", label: this.$t('common.ownerSysName'), index: 9 },
                { prop: "roleName", label: this.$t('common.roleName'), index: 10 },
                { prop: "roleResources", label: this.$t('modules.accountAssignManage.roleResources'), index: 11 },
                { prop: "roleStatus", label: this.$t('common.roleStatus'), index: 12 },
                { prop: "isDefaultRole", label: this.$t('common.isDefaultRole'), index: 13 },
                { prop: "ruleType", label: this.$t('common.ruleType'), index: 14 },
                { prop: "startTm", label: this.$t('common.startTm'), index: 15 },
                { prop: "endTm", label: this.$t('common.endTm'), index: 16 },
                { prop: "status", label: this.$t('modules.accountAssignManage.status'), index: 17 },
                { prop: "lastUpdator", label: this.$t('common.lastUpdator'), index: 18 },
                { prop: "lastUpdateTm", label: this.$t('common.lastUpdateTm'), index: 19 },
                { prop: "creator", label: this.$t('common.creator'), index: 20 },
                { prop: "createTm", label: this.$t('common.createTm'), index: 21 }
            ],
            tableVisibleArr: [],
            selectRoleList: [],
            subsysTemOptions: [],
            byStatusOptions: [
                { value: 1, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "启用" : 'enabled' },
                { value: 0, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "禁用" : 'disabled' }
            ],
            empStatusOptions: [
                { value: 1, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "在职" : 'Incumbent' },
                { value: 2, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "离职" : 'resigned' }
            ],
            roleStatusOptions: [
                { value: 1, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "启用" : 'enabled' },
                { value: 0, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "禁用" : 'disabled' }
            ],
            ruleTypeOptions: [
                { value: "A", label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "A类" : 'type A' },
                { value: "B", label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "B类" : 'type A' },
                { value: "C", label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "C类" : 'type C' }
            ],
            statusOptions: [
                { value: 1, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "启用" : 'enabled' },
                { value: 0, label: (window.sessionStorage.getItem('lang') === 'zh-CN') ? "禁用" : 'disabled' }
            ],
            isDefaultRoleOptions: [
                { value: 1, label: this.$t('common.is') },
                { value: 0, label: this.$t('common.not') }
            ],
            isSpecialOptions: [
                { value: 1, label: this.$t('common.is') },
                { value: 0, label: this.$t('common.not') }
            ],
            modifyRoletime: "",
            addRoletime: "",
            handleRoleAssignVisible: false,
            handleRoleBatchVisible: false
        }
    },
    mounted () {
        let pageObj = localStorage.getItem('basp_accountAssignManage')
        if (pageObj) {
            let obj = JSON.parse(pageObj)
            if (sessionStorage.getItem('userName')) {
                this.saveAutoDefinedTable(obj[sessionStorage.getItem('userName')])
            } else {
                this.tableVisibleArr = this.$deepCopy(this.accountAssignTableHeader, [])
            }
        } else {
            this.tableVisibleArr = this.$deepCopy(this.accountAssignTableHeader, [])
        }
        this.modifyRoletime = this.$format(new Date().getTime(), "yyyy/MM/dd")
        this.addRoletime = this.$format(new Date().getTime(), "yyyy/MM/dd")
        this.getSubSystemList() // 获取子系统
    },
    methods: {
        saveAutoDefinedTable (arr) {
            let temp = []// 配置表格可见的选项
            for (let i = 0; i < arr.length; i++) {
                temp.push(this.accountAssignTableHeader[arr[i]])
            }
            this.tableVisibleArr = temp
        },
        /**
		 * @author：xmj
		 * @function:获取子系统列表
		 */
        async getSubSystemList (val) {
            this.subsysTemOptions = await this.$getSubSystemList(val)
        },
        onSearch () {
            this.pagination.pageNum = 1
            this.searchHttp()
        },
        searchHttp () {
            let param = {
                byUserName: this.searchListForm.byUserName,
                byStatus: this.searchListForm.byStatus,
                empCode: this.searchListForm.empCode,
                empName: this.searchListForm.empName,
                empStatus: this.searchListForm.empStatus,
                positionName: this.searchListForm.positionName,
                orgName: this.searchListForm.orgName,
                netCode: this.searchListForm.netCode,
                subSystemCode: this.searchListForm.subSystemName,
                roleName: this.searchListForm.roleName,
                roleStatus: this.searchListForm.roleStatus,
                ruleType: this.searchListForm.ruleType,
                status: this.searchListForm.status,
                startTm: this.searchListForm.startTm,
                endTm: this.searchListForm.endTm,
                pageNum: this.pagination.pageNum,
                pageSize: this.pagination.pageSize
            }
            this.loading = true
            let that = this
            this.$httpExt().post('/dev-basp-user/userRole/queryList', param).then((response) => {
                if (response.succ === "ok") {
                    that.loading = false
                    that.pagination.totalSize = response.result.totalSize
                    that.accountAssignList = response.result.data
                }
            }, (response) => {
                Notification.error({
                    title: this.$t('common.exception'),
                    message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                })
            })
        },
        getSearchAreaName (val) {
            switch (val) {
            case "subsysName":
                for (var b = 0; b < this.subsysTemOptions.length; b++) {
                    if (this.searchListForm.subSystemName === this.subsysTemOptions[b].value) {
                        return this.subsysTemOptions[b].label
                    }
                }
                return this.$t('common.all')
            case "roleStatus":
                for (var c = 0; c < this.roleStatusOptions.length; c++) {
                    if (this.searchListForm.roleStatus === this.roleStatusOptions[c].value) {
                        return this.roleStatusOptions[c].label
                    }
                }
                return this.$t('common.all')
            case "empStatus":
                for (var e = 0; e < this.empStatusOptions.length; e++) {
                    if (this.searchListForm.empStatus === this.empStatusOptions[e].value) {
                        return this.empStatusOptions[e].label
                    }
                }
                return this.$t('common.all')
            case "byStatus":
                for (var f = 0; f < this.byStatusOptions.length; f++) {
                    if (this.searchListForm.byStatus === this.byStatusOptions[f].value) {
                        return this.byStatusOptions[f].label
                    }
                }
                return this.$t('common.all')
            case "ruleType":
                for (var g = 0; g < this.ruleTypeOptions.length; g++) {
                    if (this.searchListForm.ruleType === this.ruleTypeOptions[g].value) {
                        return this.ruleTypeOptions[g].label
                    }
                }
                return this.$t('common.all')
            case "status":
                for (var h = 0; h < this.statusOptions.length; h++) {
                    if (this.searchListForm.status === this.statusOptions[h].value) {
                        return this.statusOptions[h].label
                    }
                }
                return this.$t('common.all')
            default : return this.searchListForm[val];
            }
        },
        // 将表格的数据格式化;
        formatter (row, column) {
            switch (column.property) {
            case "isDefaultRole":
                for (var i = 0; i < this.isDefaultRoleOptions.length; i++) {
                    if (row.isDefaultRole == this.isDefaultRoleOptions[i].value) {
                        return this.isDefaultRoleOptions[i].label
                    }
                }
                return row.isDefaultRole
            case "isSpecial":
                for (var a = 0; a < this.isSpecialOptions.length; a++) {
                    if (row.isSpecial == this.isSpecialOptions[a].value) {
                        return this.isSpecialOptions[a].label
                    }
                }
                return row.isSpecial
            case "status":
                for (var b = 0; b < this.statusOptions.length; b++) {
                    if (row.status == this.statusOptions[b].value) {
                        return this.statusOptions[b].label
                    }
                }
                return row.status
            case "byStatus":
                for (var c = 0; c < this.statusOptions.length; c++) {
                    if (row.byStatus == this.statusOptions[c].value) {
                        return this.statusOptions[c].label
                    }
                }
                return row.byStatus
            case "empStatus":
                for (var d = 0; d < this.empStatusOptions.length; d++) {
                    if (row.empStatus == this.empStatusOptions[d].value) {
                        return this.empStatusOptions[d].label
                    }
                }
                return row.empStatus
            case "roleStatus":
                for (var e = 0; e < this.statusOptions.length; e++) {
                    if (row.roleStatus == this.statusOptions[e].value) {
                        return this.statusOptions[e].label
                    }
                }
                return row.roleStatus
            case "startTm":return this.$format(row.startTm, "yyyy/MM/dd hh:mm:ss")
            case "endTm":return this.$format(row.endTm, "yyyy/MM/dd hh:mm:ss")
            case "lastUpdateTm":return this.$format(row.lastUpdateTm, "yyyy/MM/dd hh:mm:ss")
            case "createTm":return this.$format(row.createTm, "yyyy/MM/dd hh:mm:ss")
            default : return row[column.property]
            }
        },
        resetSearch () {
            this.$refs["searchListForm"].resetFields()
        },
        midifyRole () {
            // 这里修改的时候分为三种情况；
            if (this.selectRoleList.length == 1 && (this.selectRoleList[0].endTm - new Date().getTime() < 0)) {
                MessageBox({
                    message: (window.sessionStorage.getItem('lang') == 'zh-CN') ? '该角色授权的失效日期在今天之前,无法修改授权的有效时间和失效时间!' : 'The expiration date of the role authorization is before today, and the expiration time and expiration time of the authorization can not be modified!',
                    confirmButtonText: this.$t('common.iknow')
                })
            } else if (this.selectRoleList.length == 1 && (this.selectRoleList[0].endTm - new Date().getTime() >= 0) && (this.selectRoleList[0].startTm - new Date().getTime() < 0)) {
                this.currentParentDate.startTm = this.selectRoleList[0].startTm
                this.currentParentDate.endTm = this.selectRoleList[0].endTm
                this.modifyRoleValidityVisible = true
            } else {
                MessageBox({
                    message: (window.sessionStorage.getItem('lang') == 'zh-CN') ? '请只选择一条数据进行操作!' : 'Please select only one data for operation!',
                    confirmButtonText: this.$t('common.iknow')
                })
            }
        },
        dbmidifyRole (row, event) {
            this.currentParentDate.startTm = row.startTm
            this.currentParentDate.endTm = row.endTm
            this.modifyRoleValidityVisible = true
            this.rowObject = row
        },
        batchDisabled () {
            if (this.selectRoleList.length > 0 && this.searchListForm.status == 1) {
                this.$confirm(this.$t('modules.accountAssignManage.disableWornTip'), this.$t('common.tip'), {
                    confirmButtonText: this.$t('common.submitOption'),
                    cancelButtonText: this.$t('common.cancelOption'),
                    type: 'warning'
                }).then(() => {
                    this.changeRoleStatus(0)
                }).catch(() => {
                })
            } else if (this.selectRoleList.length > 0 && this.searchListForm.status === 0) {
                MessageBox({
                    message: this.$t('modules.accountAssignManage.currentStatusTip'),
                    confirmButtonText: this.$t('common.iknow')
                })
            } else {
                MessageBox({
                    message: (window.sessionStorage.getItem('lang') === 'zh-CN') ? '请至少选择一条数据进行操作!' : 'Please select at least one data for operation!',
                    confirmButtonText: this.$t('common.iknow')
                })
            }
        },
        changeRoleStatus (status) {
            let param = {
                idList: [],
                status: status,
                systemId: 1
            }
            param.idList = []
            this.selectRoleList.map(function (item, key, ary) {
                param.idList.push({ "byAccountId": item.byAccountId, "roleId": item.roleId, id: item.id })
            })
            this.$httpExt().post('/dev-basp-user/userRole/state', param).then((response) => {
                if (response.succ === "ok") {
                    this.onSearch()
                    this.$message({
                        type: 'success',
                        message: (window.sessionStorage.getItem('lang') == 'zh-CN') ? '禁用角色成功!' : 'Disabling role success！'
                    })
                }
            }, (response) => {
                Notification.error({
                    title: this.$t('common.exception'),
                    message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                })
            })
        },
        changeSelectedRoleList (value) {
            this.selectRoleList = value
        },
        // 双击表格的某一行表格显示对应的角色修改;
        pageSizeChange (val) {
            this.pagination.pageNum = 1
            this.pagination.pageSize = val
            this.searchHttp()
        },
        handleCurrentChangePage (val) {
            this.pagination.pageNum = val
            this.searchHttp()
        },
        modifyRoleValidityClose () {
            this.modifyRoleValidityVisible = false
        },
        submitRoleValidity (dialogForm) {
            let that = this
            let urlH = '/dev-basp-user/userRole/update'
            let param = {
                startTm: dialogForm.startTm,
                endTm: dialogForm.endTm,
                systemId: 1
            }
            if (this.rowObject.byAccountId) { // 在双击的时候取byAccountId和roleId，从双击的那一行中取；
                param.byAccountId = that.rowObject.byAccountId
                param.roleId = that.rowObject.roleId
                param.id = that.rowObject.id
            } else { // 在勾选的时候取byAccountId和roleId；
                param.byAccountId = that.selectRoleList[0].byAccountId
                param.roleId = that.selectRoleList[0].roleId
                param.id = that.selectRoleList[0].id
            }
            let loadingInstance = Loading.service({ fullscreen: true })
            this.$httpExt().post(urlH, param)
                .then((response) => {
                    if (response.succ === "ok") {
                        this.modifyRoleValidityVisible = false
                        this.onSearch()
                        loadingInstance.close()
                        Notification.success({
                            title: this.$t('modules.accountAssignManage.success'),
                            message: this.$t('modules.accountAssignManage.modifyRoleSuccess')
                        })
                    }
                }, (response) => {
                    loadingInstance.close()
                    Notification.error({
                        title: this.$t('common.exception'),
                        message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                    })
                })
        },
        // 授权角色相关操作
        giveupFun (val) {
            this.$confirm(this.$t('modules.accountAssignManage.giveUpEditWornTip'), this.$t('common.tip'), {
                confirmButtonText: this.$t('common.submitOption'),
                cancelButtonText: this.$t('common.cancelOption')
            }).then(() => {
                this[val] = false
            }).catch(() => {
            })
        },
        roleHandleSave (form, arr) {
            let urlH = '/dev-basp-user/userRole/add'
            let param = {
                endTm: form.endTm,
                startTm: form.startTm,
                isDefaultRole: 0,
                idList: [],
                status: 1
            }
            arr.map(function (item, key, ary) {
                param.idList.push({ "byAccountId": form.byAccountId, "roleId": item.roleId })
            })
            let loadingInstance = Loading.service({ fullscreen: true })
            this.$httpExt().post(urlH, param)
                .then((response) => {
                    loadingInstance.close()
                    this.$message({
                        message: response.msg ? response.msg : (window.sessionStorage.getItem('lang') === 'zh-CN') ? '角色授权成功！' : 'Authorizing role success！',
                        type: 'success'
                    })
                    this.selectRoleList = []// 清空当前页面勾选项
                    this.pagination.currentPage = 1
                    this.onSearch()
                    this.handleRoleAssignVisible = false
                }, (response) => {
                    loadingInstance.close()
                    Notification.error({
                        title: this.$t('common.exception'),
                        message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                    })
                })
        },
        roleHandleBatchSave (form, arr) { // 批量申请角色
            let urlH = '/dev-basp-user/userRole/add'
            let param = {
                endTm: form.endTm,
                startTm: form.startTm,
                isDefaultRole: 0,
                idList: [],
                status: 1
            }
            arr.map(function (item, key, ary) {
                param.idList.push({ "byAccountId": item.byAccountId, "roleId": form.roleName })
            })
            let loadingInstance = Loading.service({ fullscreen: true })
            this.$httpExt().post(urlH, param)
                .then((response) => {
                    loadingInstance.close()
                    this.$message({
                        message: response.msg ? response.msg : (window.sessionStorage.getItem('lang') === 'zh-CN') ? '角色授权成功！' : 'Authorizing role success！',
                        type: 'success'
                    })
                    this.selectRoleList = []// 清空当前页面勾选项
                    this.pagination.currentPage = 1
                    this.onSearch()
                    this.handleRoleBatchVisible = false
                }, (response) => {
                    loadingInstance.close()
                    Notification.error({
                        title: this.$t('common.exception'),
                        message: response.msg ? response.msg : this.$t('common.exceptionWornText')
                    })
                })
        }
    }
}
</script>
<style lang="less" scoped>
@import "../common/css/common.less";
.accountAssignMange {
	.el-form-item__label{
		display:inline-block;
		width:110px;
	}
}
.accountAssignMange /deep/.el-pagination__rightwrapper {
	display:inline-block;
	float:none;
}
.el-pagination{
	text-align: center;
}
.el-checkbox+.el-checkbox {
	margin-left:0px;
}
.el-checkbox{
	width:120px;
}
.accountAssignMange/deep/.el-transfer-panel{
	width:40%;
}
</style>
